/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hcsc.datapower.CMDB.ConnectionFactories;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author I307211
 */
public class MSAccessConnectionFactory {
    private String driverClassName = "sun.jdbc.odbc.JdbcOdbcDriver";
    private String connectionURL = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Documents and Settings\\I307211\\Desktop\\CMDB\\test\\DataPower.mdb";
    private Connection Con;
    
    private static MSAccessConnectionFactory connectionFactory = null;
    
    private MSAccessConnectionFactory(){
        try {
            Class.forName(driverClassName);
        }catch ( ClassNotFoundException e){
            e.printStackTrace();
        }
    }
    
    public Connection getConnection() throws SQLException {
        Con = DriverManager.getConnection(connectionURL, "", "");
        return Con;
    }
    
    public static MSAccessConnectionFactory getInstance(){
        if(connectionFactory==null){
            connectionFactory = new MSAccessConnectionFactory();
        }
        return connectionFactory;
    }
}
